/*
 * @Author: jipeng.Li
 * @Date: 2020-01-16  14:26:52.91
 * @LastEditors: jipeng.Li
 * @LastEditTime: 2020-01-16  14:26:52.91
 * @Description: 运单线
 */
import React, { Component, useState } from 'react';
import {
  StyleSheet,
  ListView,
  Image,
  View,
  Text,
  TouchableOpacity
} from 'react-native';
import {
  px2dp,
  fontColorBlack,
  fontColorSecDeepGray,
  fontColorDeepGray
} from "../../../../../../common/styles";
import FlagView from "../../../source/components/FlagView";

const WaybillLine = (props) => {
  const {
    type = 1,
    lineIsShow = true,
    lineHeight = 100,
    lineText = '',
    sources,
    renderInfoItem = () => {}
  } = props;
  return (
    <View>
      <View style={styles.container}>
        <View style={styles.waybillLineContainer}>
          <FlagView tips={ type === 1 ? '起' : '终'} colors={ type === 1 ?  ['#7EE35E', '#2CBD26'] : ['#F48F25', '#EB2F2F',] } />
          { lineIsShow && (
            <View style={styles.dashLine}>
              <View style={[styles.lineStyle, {height: px2dp(lineHeight)}]} />
            </View>
          )}
        </View>
        <View
            style={styles.itemContainer}>
          {renderInfoItem(sources)}
        </View>
      </View>

      {
        lineIsShow && (
          <>
            <Text>{lineText}</Text>
            <View style={styles.waybillLineContainer}>
              <View style={styles.dashLine}>
                <View style={[styles.lineStyle, {height: px2dp(60)}]} />
              </View>
            </View>
          </>
        )
      }
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flexDirection: 'row',
  },
  waybillLineContainer: {
    alignItems: 'center',
    padding: px2dp(5),
    width: px2dp(35),
  },
  dashLine: {
    width: px2dp(1),
    overflow: 'hidden',
    backgroundColor:'transparent',
  },
  lineStyle: {
    width: px2dp(0),
    borderColor: fontColorDeepGray,
    borderWidth: px2dp(1),
    borderStyle: 'dashed',
    borderRadius: px2dp(0.1)
  },
  itemContainer: {
    flex: 1,
  }
})

export default WaybillLine
